<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
		<title>表单 - 达内OA管理系统</title>
		<link rel="icon" href="favicon.ico" type="image/ico">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/materialdesignicons.min.css" rel="stylesheet">
		<link href="css/style.min.css" rel="stylesheet">
	</head>

	<body>
		<div class="container-fluid p-t-15">

			<div class="row">
				<div class="col-lg-12">
					<div class="card">
						<div class="card-body">

							<form class="site-form">

								<div class="form-group">
									<label for="e_aName">审批类型</label>
									<select class="form-control" id="e_aName" name="e_aName" size="1">
										<option value="1">请假</option>
										<option value="2">出差</option>
										<option value="3">报销</option>
									</select>
								</div>

								<div class="form-group">
									<label class="col-lg-12" for="e_aContent">详细描述</label>
									<div class="col-lg-12">
										<textarea class="form-control" id="e_aContent" name="e_aContent" rows="6" placeholder="请简要描述审批内容.."></textarea>
									</div>
								</div>

								<div class="form-group">
									<label for="start_date">开始时间</label>
									<input class="form-control js-datepicker m-b-10" type="text" id="start_date" name="start_date" placeholder="yyyy-mm-dd"
									 value="" data-date-format="yyyy-mm-dd" />
								</div>

								<div class="form-group">
									<label for="end_date">结束时间</label>
									<input class="form-control js-datepicker m-b-10" type="text" id="end_date" name="end_date" placeholder="yyyy-mm-dd"
									 value="" data-date-format="yyyy-mm-dd" />
								</div>

								<button id="submit2" class="btn btn-primary">保存</button>

						</div>
						</form>

					</div>
				</div>
			</div>

		</div>

		</div>

		<script type="text/javascript" src="js/jquery.min.js"></script>

		<!--时间选择插件-->
		<script src="js/bootstrap-datetimepicker/moment.min.js"></script>
		<script src="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
		<script src="js/bootstrap-datetimepicker/locale/zh-cn.js"></script>

		<!--日期选择插件-->
		<script src="js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
		<script src="js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
		<script type="text/javascript" src="js/main.min.js"></script>

		<script>
			var e_aId = ";"
			$(function() {
				var url = location.search //获取url中"?"符后的字串 ('?modFlag=business&role=1')
				var theRequest = new Object()
				if (url.indexOf('?') != -1) {
					var str = url.substr(1) //substr()方法返回从参数值开始到结束的字符串；
					var strs = str.split('&')
					for (var i = 0; i < strs.length; i++) {
						theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1]
					}
					$("#e_aName").val(decodeURI(theRequest.e_aName));
					$("#e_aContent").val(decodeURI(theRequest.e_aContent));
					$(" input[ name='start_date' ] ").val(theRequest.startTime);
					$(" input[ name='end_date' ] ").val(theRequest.endTime);

				}
			});

			$("#submit2").click(function() {
				var e_aName = $("#e_aName").val();
				var e_aContent = $("#e_aContent").val();
				var startTime = $(" input[ name='start_date' ] ").val();
				var endTime = $(" input[ name='end_date' ] ").val();

				$.ajax({
					url: "http://www.oa.com/e_a/edit",
					type: "post",
					data: {
						"e_aId":e_aId,
						"e_aType": e_aName,
						"e_aContent": e_aContent,
						"startTime": startTime,
						"endTime": endTime
					},
					dataType: "json",
					async: false,
					success: function(result) {
						//result是服务端返回的数据
						if (result.status == 200) {
							alert("添加成功！")
							location.href = "mye_a.html";
						} else {
							alert("添加失败");
						}
					},
					error: function() {
						alert("请求失败!");
					}
				});

			})
		</script>
	</body>
</html>
